import { requestClient } from '#/api/request';

// 司机相关API接口封装

/**
 * 获取司机列表（支持分页和筛选）
 */
export const getDriversApi = (params: {
  fullName?: string;
  page?: number;
  pageSize?: number;
  phoneNumber?: string;
}) => {
  return requestClient.get('/drivers/list', { params });
};

/**
 * 检查联系电话是否已存在
 */
export const checkPhoneExistsApi = (data: {
  excludeId?: number;
  phoneNumber: string;
}) => {
  return requestClient.post('/drivers/check-phone', data);
};

/**
 * 创建司机
 */
export const createDriverApi = (data: {
  emergencyContact?: string;
  firstLicenseDate?: string;
  fullName: string;
  licenseLevel?: string;
  phoneNumber: string;
}) => {
  return requestClient.post('/drivers', data);
};

/**
 * 更新司机信息
 */
export const updateDriverApi = (
  id: number,
  data: {
    emergencyContact?: string;
    firstLicenseDate?: string;
    fullName: string;
    licenseLevel?: string;
    phoneNumber: string;
  },
) => {
  return requestClient.put(`/api/drivers/${id}`, data);
};

/**
 * 分配车辆给司机
 */
export const assignVehiclesApi = (
  driverId: number,
  data: {
    vehicleIds: number[];
  },
) => {
  return requestClient.post(`/api/drivers/${driverId}/assign-vehicles`, data);
};
